#ifndef GUNBUNS_HPP_INCLUDED
#define GUNBUNS_HPP_INCLUDED

#include <list>

#include <SFML/Graphics.hpp>
#include <Box2D.h>

#include "../game_state.hpp"
#include "../singleton.hpp"

struct Gunner {
	Gunner(): shot(false) {

	}

	sf::Sprite target;
	sf::Vector2f speed;
	int ammunition;
	bool shot;
};

struct Impact {
	float time;
	sf::Sprite sprite;
};

class GunBuns: public GameState, public Singleton<GunBuns> {
	friend class Singleton<GunBuns>;
	public:
		void init(Engine *engine);
		void cleanup();

		void pause();
		void resume();

		void processEvent(Engine *engine, PlayerEvent& event);
		void update(Engine *engine);
		void draw(Engine *engine);

		b2World *phyWorld;

		float countdown;
		bool quit;
		float quitTime;
		sf::String countdownString;

		std::map<int, Gunner> gunners;
		sf::Sprite sky, background, foreground;
		sf::Clock clock;

		sf::Sprite bunny;
		float bunnyTime;
		float bunnyShotTime;
		int bunnySense;
		int bunnyDirection;

		sf::Sound shot, hit;

		std::list<Impact> impacts;
		std::list<ScoreString> scoreStrings;

	protected:
		void impact(Engine *engine, sf::Vector2f position);
		void newBunny();
		void addScore(Engine *engine, int player, int score);

		GunBuns();
		~GunBuns();
};

#endif // GUNBUNS_HPP_INCLUDED
